package sctu.edu.java.year2016.team07.liaohengju.day20160523.chapter5_3;

/**
 * Created by hengju on 2016/5/23.
 * 编写java程序，创建二维数组arr[][]，将二维数组中的所有元素的和输出。
 */
public class Zuoye5_3 {
    public static void main(String[] args) {
        int sum = 0;
        int arr[][] = {{4, 2}, {8, 5}};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j] + "\t");
            }
            System.out.println();
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                sum = sum + arr[i][j];
            }
        }
        System.out.print("二维数组所有元素的和sum=" + sum);
    }
}
